#include<sys/types.h>
#include<sys/stat.h>
#include<stdio.h>
#include<fcntl.h>
int main()
{
	int fd,num;
	//打开"/dev/CDEV_ZHU"
	fd=open("/dev/CDEV_ZHU1",O_RDWR,S_IRUSR|S_IWUSR);
	if(fd != -1)
	{
		//初次读global_var
		read(fd,&num,sizeof(int));
		printf("the globalvar is %d\n",num);

		//写global_var
		printf("please input the num written to globalvar\n");
		scanf("%d",&num);
		write(fd,&num,sizeof(int));

		//再次读global_var
		read(fd,&num,sizeof(int));
		printf("THe globalvar is %d\n",num);

		//关闭"/dev/CDEV_ZHU"
		close(fd);
	}
	else
	{
		printf("Device open failture\n");
	}
	return 0;
}
